<?php
    class Worker
    {
        private $readers = array();
        private $advs = array();
        private $allAdvs = array();
        private $keyWords_ = array();
        private $date_;
        private $htmlString ="";

        function __construct($keyWords, $date)
        {
            $this->keyWords_ = $keyWords;
            $this->date_ = $date;
        }
 
        public function addReader($reader)
        {
            $this->readers[]=$reader;
        }

        public function doIt()
        {                      
            for ($i = 0; $i < count($this->readers); $i++)
            {
                $this->advs = $this->readers['$i']->doTheWork(); // array? advs[0] or advs[]
                $this->allAdvs[]=$this->advs;
            }
            $fullString = $this->makeHtmlString();
            $skyParser = new SkyParser();
            $newString = $skyParser->htmlToXmlString($fullString);
            $xml = new XML();
            $xml->writeToXML($newString);
        }

        public function makeHtmlString()
        {
            for($i=0;$i<count($this->allAdvs);$i++)
            {
                $end = count($this->allAdvs) - 1;
                $this->htmlString .= $this->allAdvs['$i']->getContent() . "~";
                if ($i == $end)
                {
                    $this->htmlString .= $this->allAdvs['$i']->getDate();
                }
                else 
                {
                    $this->htmlString .= $this->allAdvs['$i']->getDate() . "~";
                }
            }
            return $this->htmlString;
        }
    }
?>
